package com.magenta.maxoptra.gis.utils;

import com.magenta.maxoptra.gis.GeoAddress;
import com.magenta.maxoptra.gis.GeographicCoordinates;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: kuznetsovd
 * Date: 05.12.12
 * Time: 13:24
 * To change this template use File | Settings | File Templates.
 */
public class DoReverseGeocodingProfiler extends AbstractGisProfiler{

    private String coordsDefinition = "";

    public DoReverseGeocodingProfiler(String provider, String accountGlobalId, boolean enableProfiling, List<GeographicCoordinates> coordinates) {
        super(provider, accountGlobalId, enableProfiling);
        for (GeographicCoordinates c : coordinates) {
            coordsDefinition = coordsDefinition + printPoint(c)+":";
        }
    }

    public DoReverseGeocodingProfiler(String provider, String accountGlobalId, boolean enableProfiling, GeographicCoordinates coordinate) {
        super(provider, accountGlobalId, enableProfiling);
        coordsDefinition = coordsDefinition + printPoint(coordinate);
    }

    public String getInitialInfo() {
        return provider + separator + accountGlobalId + separator + coordsDefinition;
    }

    @Override
    public void logDuration(String action) {
        super.logDuration("geocoding.reverse:"+action);
    }

    public void logDuration(int count) {
        super.logDuration("geocoding.reverse.count:"+count);
    }

    public void logDuration(GeoAddress address) {
        super.logDuration("geocoding.reverse:"+ (address!=null?address.toString():"UNKNOWN"));
    }

}
